"use strict";


/* eslint no-console:off */

// Load the input workbook from file.
const XlsxPopulate = require('../../lib/XlsxPopulate');
const path = require('path');

// Get template workbook and sheet.
XlsxPopulate.fromFileAsync(path.resolve(__dirname, './template.xlsx'))
    .then(workbook => {
        // Randomly generate 10 rows of data.
        const sheet = workbook.sheet(0);
        const rows = sheet.usedRange().value();
        rows.slice(1).forEach(row => {
            if (row[0] === undefined) return;
            const value = typeof row[0] === 'number' ? XlsxPopulate.numberToDate(row[0]) : row[0];
            console.log(value);
        });

        // Write to file.
        return workbook.toFileAsync('./out.xlsx');
    })
    .catch(err => console.error(err));
